<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>Message List</title>
  <link rel="alternate" type="application/rss+xml" title="MoTSangria Activity Log" href="<g:createLink class='message' action='feed'/>"/>
  <g:javascript library="prototype"/>
</head>
<body>
<div class="body">
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <h1>Activity Log <g:if test="${filter}">von ${filter}</g:if><g:else>des MoTSangria Teams</g:else></h1>
  <g:isLoggedIn>
    <div id="newPost">
<input id="charLeft" name="charLeft" size="5" value="255" readonly="true"/>
    <g:form action="save">
      <input type="hidden" id="user.id" name="user.id" value="<g:loggedInUserInfo field='id'/>">
      <input type="hidden" id="medium" name="medium" value="MoTSangria Homepage">
      <textarea id="messageTextArea" name="content" onkeydown="updateCounter()" rows="3" cols="50"></textarea><br/>
      <g:submitButton id="messageSubmitButton" name="post" value="Nachricht absenden"/>
    </g:form>
  </div>
    <g:javascript>
      function updateCounter() {
        $("charLeft").value = "Noch " + (255 - $F("messageTextArea").length) + " Zeichen."
      }
      updateCounter();
    </g:javascript>
  </g:isLoggedIn>
  <div id="allPosts">

    <g:each status="i" var="messageInstance" in="${messageInstanceList}">
      <g:form>
        <input type="hidden" name="id" value="${messageInstance?.id}"/>
        <div class="messageContent">
          <div class="messageImage">
            <a href="<g:createLink controller="profile" action="show" id="${messageInstance?.user?.profile?.id}"/>"><img border="0" src="<g:createLink controller="image" action="tiny" id="${messageInstance?.user?.id}"/>" alt="${messageInstance?.user?.username}"/></a>
          </div>
          <div class="messageEntry">
            <div class="${(i == 0 && (params.offset == null || params.offset == '0')) ? 'firstMessageText' : 'messageText'}">
              <a href="<g:createLink controller="message" action="user" id="${messageInstance?.user?.id}"/>">${messageInstance?.user}</a>: ${messageInstance?.content}
              <g:if test="${messageInstance?.link}"><a href="${messageInstance?.link}" target="_blank">[More]</a></g:if>
            </div>
            <g:isLoggedIn>
            <g:actionSubmit style="float:right" class="messageDeleteButton" onclick="return confirm('Are you sure?');" value=" " action="Delete"/>
            </g:isLoggedIn>
            <div class="messageDate">
              <g:dateFromNow date="${messageInstance?.dateCreated}"/> via ${messageInstance?.medium}
            </div>
          </div>
        </div>
      </g:form>
    </g:each>

  </div>
  <div class="paginateButtons">
    <g:paginate total="${Message.count()}"/>
    <span><a href="<g:createLink class='message' action='feed'/>"><img src="${createLinkTo(dir: 'images', file: 'feed.gif')}" alt='Rss Feed' border='0'/></a></span>
  </div>

  

</div>
</body>
</html>
